home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-07 | 2.2 KB | 88 lines | [TEXT/MPS ] |
- (*
- CTBSwitch([newToolID[,type]]) -- Return the ID of the current tool of the type specified (default:
- connection). If newToolID is present, then switch to that tool; if it is "new", then prepare to
- allocate a new tool.
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- pascal -w CTBSwitch.p
- link -m ENTRYPOINT -o HyperCommands -rt XFCN=2757 -sn Main=CTBSwitch ∂
- CTBSwitch.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
-
- © Copyright 1990 by Apple Computer, Inc.
-
- Initial coding 2/90 by Harry R. Chesley.
- *)
-
- {$R-}
-
- {$S CTBSwitch } { Segment name must be the same as the command name. }
-
- unit DummyUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- implementation
-
- procedure CTBSwitch(paramPtr: XCmdPtr); forward;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- begin
- CTBSwitch(paramPtr);
- end;
-
- procedure CTBSwitch(paramPtr: XCmdPtr);
-
- {$I CTBUtil.inc}
-
- var tt: ToolType;
- toolID: longInt;
- s: Str255;
-
- procedure Fail(errMsg: Str255); { set theResult and quit }
- begin
- paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
- exit(CTBSwitch);
- end;
-
- begin
- { Check the parameter count. }
- if paramPtr^.paramCount > 2 then Fail('Invalid parameter count');
-
- { Figure out which type of tool. }
- if not ParmPresent(2) then tt := connectionTool
- else tt := GetToolTypeParm(2);
-
- { Make sure the Comm Toolbox is around. }
- CTBReady;
-
- { Get the current tool handle (which we'll return as the ID). }
- case tt of
- connectionTool: toolID := ord4(Globals^^.connHand);
- terminalTool: toolID := ord4(Globals^^.termHand);
- fileTransferTool: toolID := ord4(Globals^^.FTHand);
- end;
- { Convert it to a string and return it. }
- LongToStr(paramPtr,toolID,s);
- paramPtr^.returnValue := PasToZero(paramPtr,s);
-
- { Check if we're to set a new one. }
- if ParmPresent(1) then
- begin
- { Set it (note: "new" will translate to 0). }
- toolID := GetLongParm(1);
- case tt of
- connectionTool: Globals^^.connHand := ConnHandle(toolID);
- terminalTool: Globals^^.termHand := TermHandle(toolID);
- fileTransferTool: Globals^^.FTHand := FTHandle(toolID);
- end;
- end;
- end;
-
- end.
-